package com.ciaojian.core.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.io.Serializable;

/**
 * Service 基类
 * 对 ServiceImpl 的扩展
 *
 * @author oxiny
 */
public class BaseService<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {

    /**
     * 数据是否已存在
     *
     * @return /
     */
    public Boolean existById(Serializable id) {
        T entity = super.getById(id);
        return entity != null;
    }

    /**
     * 数据是否存在
     *
     * @param column 列
     * @param value  值
     * @return /
     */
    public Boolean exist(String column, Object value) {
        Integer count = this.query().eq(column, value).count();
        return count > 0;
    }

}
